package com.springbootee.Config;

import com.fasterxml.jackson.databind.ObjectMapper;

import com.springbootee.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @name: TestRedis
 * @author: 你的辰宝
 * @time: 2021/11/3 18:57
 * @deprecated :  注释
 */
@RestController
@RequestMapping("/reids")
public class TestRedis {
        @Autowired
        private RedisTemplate redisTemplate;


        /**
          *@deprecated: TestRedis
          *@parms: * @Param key:
         * @Param value:
          *@return: * @return: java.lang.String
          *@author: 你的辰宝
          *@time: 2021/11/3 19:59
         * 测试一个reids
         */
        @GetMapping("/string/add")
         public  String  addStringKeyValue(@RequestParam(value = "key",defaultValue = "key1") String key,@RequestParam(value = "value",defaultValue = "redis value") String value){
            redisTemplate.opsForValue().set(key,value);
            return (String) redisTemplate.opsForValue().get(key);
         }

//         @GetMapping("object/add")
//          public  Object  addObejctKeyValue(@RequestParam(value = "key",defaultValue = "key1") String key){
//                User user=new User(5,"黎明","18","male");
//                redisTemplate.opsForValue().set(key,user);
//                return  redisTemplate.opsForValue().get(key);
//         }
         @GetMapping("/string/get")
        public Object getStringByKey(@RequestParam(value = "key",defaultValue = "key1") String key){
            return  redisTemplate.opsForValue().get(key);
         }

}
